﻿using System;
using System.CodeDom;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
using Microsoft.CSharp;

namespace NutriStat
{
    /// <summary>
    /// Base form for the NutriStat project, from which all forms inherit.
    /// </summary>
    public partial class NutriForm : FormBase
    {
        #region Constructors
        /// <summary>
        /// Default constructor
        /// </summary>
        public NutriForm() : base()
        {
            InitializeComponent();

            Application.Idle += new System.EventHandler(FormBase_OnIdle);
        }
        #endregion Constructors


        /// <summary>
        /// Updates the form's status bar.
        /// </summary>
        protected override void UpdateStatusBar()
        {
            Assembly a = Assembly.GetExecutingAssembly();
            //assemblyVersion = a.GetName().Version;

            object[] customAttributes;
            Version assemblyInformationalVersion;

            customAttributes = a.GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false);
            if (customAttributes.Length == 1)
            {
                assemblyInformationalVersion = new Version(((AssemblyInformationalVersionAttribute)customAttributes[0]).InformationalVersion);
                tsslVersion.Text = assemblyInformationalVersion.ToString();
            }

            UpdateStatusBarKeys();
        }

        /// <summary>
        /// Updates the status bar's keyboard labels.
        /// </summary>
        protected override void UpdateStatusBarKeys()
        {
            if (Control.IsKeyLocked(Keys.NumLock))
            {
                tsslNUM.Enabled = true;
            }
            else
            {
                tsslNUM.Enabled = false;
            }

            if (Control.IsKeyLocked(Keys.CapsLock))
            {
                tsslCAPS.Enabled = true;
            }
            else
            {
                tsslCAPS.Enabled = false;
            }

            if (Control.IsKeyLocked(Keys.Insert))
            {
                tsslINS.Enabled = true;
            }
            else
            {
                tsslINS.Enabled = false;
            }
        }
    } // end class
} // end namespace
